<template>
    <div class="content">
        <div class="top-content">
            <div class="box">
                <div class="left-box">
                    实验室用低温操作台（工作台）、血液低温操作台（工作台）、医用洁净工作台、低温洁净工作台、低温配血台、血液配血台、低温操作台（工作台）价格、低温操作台（工作台）厂家
                </div>
                <div class="top-content-right">
                    <div class="tel-box">
                        咨询热线：{{ webMessage.tel1 }} {{ webMessage.tel2 }}
                    </div>
                </div>
            </div>
        </div>
        <div class="logo-box">
            <div class="img-box banner-box">
                <div class="img">
                    <img src="../assets/ui/logo.png" alt="">
                    <span></span>
                    <div>
                        <h1>
                            专业提供实验室用低温操作台（工作台）、血液低温操作台（工作台）
                        </h1>
                        <h2>医用洁净工作台、低温洁净工作台、低温配血台、血液配血台、低温操作台（工作台）价格、低温操作台（工作台）厂家</h2>
                    </div>
                </div>
                <div class="title">
                    <h1>24h服务热线:</h1>
                    <h2>{{ webMessage.tel1 }}</h2>
                    <h2>{{ webMessage.tel2 }}</h2>
                </div>
            </div>
        </div>
        <div class="top-list">
            <div class="box">
                <div class="list-box">
                    <div class="item" @click="gotoweb('/')">网站首页</div>
                    <div class="item" v-for="(item, index) in topList" :key="index"
                        @click="gotoChanpin(item.record_id)">
                        {{ item.title }}
                    </div>
                    <div class="item" v-for="(item, index) in userRouterJson" :key="index" @click="gotoweb(item.path)">
                        {{ item.title }}
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import router from '@/router/index.js'
import { getTopList, getWebXinxi } from '@/api/viewapi.js'
import { ref, reactive, onMounted } from 'vue'


const webMessage = ref({})

const topList = ref([])

const gotoweb = (path) => {
    router.push(path)
}

const getWebMessage = () => {
    getWebXinxi().then((res) => {
        webMessage.value = res.data.data
        console.log(res);
    })
}

const _getTopList = () => {
    getTopList().then((res) => {
        topList.value = res.data.toplist_ids
        console.log(res);
    })
}

// 跳转商品列表 
const gotoChanpin = (id) => {
    router.push({ path: '/chanpinlist', query: { id: id } })
}

// 路由图 
const userRouterJson = [
    {
        title: '新闻中心',
        path: '/news'
    }, {
        title: '关于我们',
        path: '/about'
    }, {
        title: '联系我们',
        path: '/telme'
    }
]


onMounted(() => {
    getWebMessage()
    _getTopList()
})
</script>

<style scoped lang="scss">
// 取消显示pc端 显示手机端
@media screen and (max-width: 799px) {
    .content {
        .top-content {
            .box {
                .left-box {
                    padding: 14px 4px;
                    background: linear-gradient(0deg, rgba(0, 109, 196, 1) 0%, rgba(28, 189, 240, 1) 100%);
                    color: white;
                }

                .top-content-right {
                    display: none;
                }
            }
        }

        .logo-box {
            padding: 10px;
            border-bottom: 1px solid gainsboro;

            .img-box {
                .img {
                    display: flex;

                    img {
                        margin-top: 20px;
                        width: 60px;
                        height: 65px;
                    }

                    span {
                        margin-left: 10px;
                        margin-right: 10px;
                        display: block;
                        height: 110px;
                        width: 1px;
                        background-color: #999999;
                    }

                    div {
                        padding: 16px 0;

                        h1 {
                            font-size: 14px;
                            display: inline;
                            margin: 0;

                            p {
                                font-size: 24px;
                                color: #2a73d4;
                            }
                        }

                        h2 {
                            font-size: 12px;
                        }
                    }
                }

                .title {
                    border-top: 1px solid gainsboro;
                    padding: 20px 0;
                    display: flex;
                    justify-content: space-around;
                    font-size: 18px;
                    h2 {
                        font-size: 20px;
                        color: #00a0e9;
                        font-weight: 800;
                    }
                }
            }
        }

        .top-list {
            .box {

                .list-box {
                    display: grid;
                    grid-template-columns: repeat(4, 1fr);
                    /* 创建4列，每列占1fr */
                    gap: 2px;

                    /* 设置列与列之间的间距 */
                    .item {
                        padding: 14px 0;
                        font-size: 14px;
                        text-align: center;
                        background-color: #00a0e9;
                        color: white;
                    }
                }
            }
        }
    }
}

// 显示pc端
@media (min-width: 800px) {
    .phone {
        display: none;
    }
    .content {
        .top-content {
            background-color: rgb(245, 245, 245);

            .box {
                margin: 0 auto;
                max-width: 1400px;
                padding: 10px 40px;
                display: flex;
                justify-content: space-between;
                font-size: 14px;
                color: #999999;


                .left-box {
                    display: flex;

                    .item {

                        cursor: pointer;
                        margin-right: 40px;
                    }
                }

                .top-content-right {
                    .tel-box {}
                }
            }
        }

        .logo-box {
            padding: 20px 0;

            .img-box {
                display: flex;
                justify-content: space-between;

                .img {
                    display: flex;

                    span {
                        margin-left: 20px;
                        margin-top: 10px;
                        display: block;
                        height: 60px;
                        background-color: black;
                        width: 1px;
                        margin-right: 10px;
                    }

                    div {
                        padding: 20px;

                        h1 {
                            font-size: 18px;
                            display: flex;

                            p {
                                color: #2a73d4;
                            }
                        }
                    }
                }

                .title {
                    margin-right: 40px;

                    h1 {
                        font-size: 18px;
                    }

                    h2 {
                        font-size: 20px;
                        color: #2a73d4;
                        font-weight: 800;
                    }
                }
            }
        }

        .top-list {
            padding-top: 20px;
            padding-bottom: 20px;
            background: linear-gradient(0deg, rgba(0, 109, 196, 1) 0%, rgba(28, 189, 240, 1) 100%);

            .box {
                max-width: 1400px;
                margin: 0 auto;

                .list-box {
                    display: flex;
                    font-size: 16px;
                    justify-content: space-between;

                    .item {
                        line-height: 40px;
                        padding: 0 10px;
                        cursor: pointer;
                        transition: transform 0.3s ease, background-color 0.3s ease;
                        border-radius: 4px;
                        margin-left: 10px;
                        color: white;

                    }

                }
            }
        }
    }
}
</style>
